<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<title>fangbing</title>
<link href="/res/css/bootstrap.css" rel="stylesheet">
<link href="/res/css/metisMenu.css" rel="stylesheet">
<link href="/res/css/fullcalendar.css" rel="stylesheet">
<link href="/res/css/jquery-ui.css" rel="stylesheet">
<link href="/res/css/sb-admin-2.css" rel="stylesheet">
<link href="/res/css/font-awesome.css" rel="stylesheet">

<script src="/res/js/moment.js"></script>
<script src="/res/js/jquery-2.1.4.js"></script>
<script src="/res/js/bootstrap.js"></script>
<script src="/res/js/jquery-ui.js"></script>
<script src="/res/js/fullcalendar.js"></script>
<script src="/res/js/metisMenu.js"></script>
<script src="/res/js/sb-admin-2.js"></script>
</head>

<body>
	<div class="row">
		<div class="col-lg-12">
			<div class="panel panel-default panel-success">
				<div class="panel-heading">
					<h1>
						用户信息 <small>新增用户信息</small>
					</h1>
				</div>
				<div class="panel-body">
					<form class="form-horizontal" id ="submitForm" method="post">
						<div class="form-group">
							<label for="username" class="col-sm-2 control-label">用户名</label>
							<div class="col-sm-10">
							<input type="hidden" class="form-control" name = "id" id="id"
									 value="${user.id}">
								<input type="text" class="form-control" name = "userName" id="username"
									placeholder="必须输入" value="${user.userName}">
							</div>
						</div>
						<div class="form-group">
							<label for="password" class="col-sm-2 control-label">密码</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="passWord" id="password"
									placeholder="必须输入" value="${user.passWord}">
							</div>
						</div>
						<div class="form-group">
							<label for="password1" class="col-sm-2 control-label">确认密码</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="password1" 
									placeholder="必须输入" value="${user.passWord} ">
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-offset-2 col-sm-10">
							<c:if test="${user.id==null}">
								<button type="button" id = "add" class="btn btn-default">保存</button>
							</c:if>
							<c:if test="${user.id!=null}">
								<button type="button" id = "update" class="btn btn-default">修改</button>
							</c:if>
								<button type="button" id = "return" class="btn btn-default">取消</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</body>
<script>
        $("#return").click(function(){
        	window.location.href = "/user/searchUserList.do";
        });
        
        $("#add").click(function(){
        	alert("保存成功！");
        	$("#submitForm").attr("action", "/user/save.do");
            $("#submitForm").submit();
        });
        
        $("#update").click(function(){
        	$("#submitForm").attr("action", "/user/update.do");
            $("#submitForm").submit();
        });
        
</script>
</html>
